<?php 

/**
* 购物车模型
*/
class CartModel extends Model{
	// 设置模型对象
	public $table="cart";
	
	public function get_data(){
		return $this->all();
	}
	/**
	 * [add_data 增加购物车的方法]
	 */
	public function add_data($data){
		$this->data['cartinfo'] = $data;
		$this->data['uid'] =$_SESSION['uid'];
		return $this->add();
	}
	/**
	 * [get_one_data 获取一条数据]
	 * @param  [type] $where [description]
	 * @return [type]        [description]
	 */
	public function get_one_data($where = NULL){
		return $this->where($where)->find();
	}
	/**
	 * [del_data 删除数据]
	 * @param  [type] $cid [description]
	 * @return [type]      [description]
	 */
	public function del_data($where = NULL){
		$this->where($where)->delete(); 
		return true;
	}
	/**
	 * [update_data 更新购物车]
	 * @return [type] [description]
	 */
	public function update_data($where=NULL,$data=NULL){
		$this->data['cartinfo'] = $data;
		$this->where($where)->save();
	}
}

 ?>